<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            display: flex;
            align-items: center;
        }
    </style>
</head>

<body>
    <input type="text">
    <button>发布</button>
    <ul>

    </ul>
    <script>
        const text = document.querySelector("input")
        const button = document.querySelector("button")
        const ul = document.querySelector("ul")
        button.addEventListener("click", function () {
            if (text.value.trim() !== "") {
                const textValue = text.value.trim()
                const li = document.createElement("li")
                const button = document.createElement("button")
                button.innerHTML = "删除"
                button.dataset.delete = 'delete'
                li.innerHTML = textValue.replace(/激情|基情/g, "**")
                li.append(button)
                ul.append(li)
                text.value = ""
            }
        })

        document.body.addEventListener("click", function (e) {
            const deleteButton = e.target.dataset.delete
            if (deleteButton === "delete") {
                e.target.parentNode.parentNode.removeChild(e.target.parentNode)
            }


        })

    </script>
</body>

</html>